import request from "@/config/request";

// 获取用户的频道
export const getUserService = () => {
    return request({
        method: 'GET',
        url: '/v1_0/user/channels'
    })
}

// 获取所有频道数据
export const getAllService = () => {
    return request({
        method: 'GET',
        url: '/v1_0/channels'
    })
}

// 登录
export const postUserSignIn = data => {
        return request({
            method: 'POST',
            url: '/v1_0/authorizations',
            data
        })
    }
    /**
     * 验证码
     */
export const getUserMobile = mobile => {
    return request({
        method: 'GET',
        url: `/v1_0/sms/codes/${mobile}`,
    })
}

/**
 * 获取用户自己的信息
 */

export const getUserMyData = () => {
    return request({
        method: 'GET',
        url: '/v1_0/user'

    })
}

/**
 * 编制用户个人资料
 */
export const patchEditUserProfile = data => {
    return request({
        method: 'PATCH',
        url: '/v1_0/user/profile',
        data
    })
}

/**
 * 获取用户个人资料
 */

export const getUserMyProfile = () => {
    return request({
        method: 'GET',
        url: '/v1_0/user/profile'
    })
}

/**
 *  编辑用户照片资料
 */
export const editUserPhoto = data => {
    return request({
        method: 'PATCH',
        url: '/v1_0/user/photo',
        data
    })
}

/**
 * 
 * 添加频道
 */
export const addUserChannels = data => {
    return request({
        method: 'PATCH',
        url: '/v1_0/user/channels',
        data: {
            channels: [data]
        }
    })
}

/**
 * 删除频道
 */
export const deleteUserChannel = target => {
    return request({
        method: 'DELETE',
        url: `/v1_0/user/channels/${target}`
    })
}

/**
 * 获取新闻推荐
 */
export const getPushArticles = params => {
    return request({
        methods: 'GET',
        url: '/v1_0/articles',
        params,
    })
}

/**
 * 获取搜索结果数据
 */
export const getSearchResult = params => {
    return request({
        method: 'GET',
        url: '/v1_0/search',
        params,
    })
}

/**
 * 联想建议搜索数据
 */
export const getSuggesTions = params => {
    return request({
        method: 'GET',
        url: '/v1_0/suggestion',
        params
    })
}

/**
 * 新闻详情
 */
export const getArticlesDetails = article_id => {
    return request({
        method: 'GET',
        url: `/v1_0/articles/${article_id}`
    })
}

/**
 * 获取文章评论详情
 */
export const getUserComment = params => {
    return request({
        method: 'GET',
        url: '/v1_0/comments',
        params
    })
}

/**
 * 对评论跟评论回复点赞
 */
export const postCommentLikings = target => {
    return request({
        method: 'POST',
        url: '/v1_0/comment/likings',
        data: {
            target
        }
    })
}

/**
 * 取消评论点赞
 */
export const deleteArticleComment = id => {
    return request({
        method: 'DELETE',
        url: `/v1_0/comment/likings/${id}`
    })
}

/**
 * 对文章或者文章评论经行评论回复
 */
export const postArticleComment = data => {
    return request({
        method: 'POST',
        url: '/v1_0/comments',
        data
    })
}

/**
 * 对文章进行点赞
 */
export const postArticleLikings = data => {
    return request({
        method: 'POST',
        url: '/v1_0/article/likings',
        data
    })
}

/**
 * 取消对文章的点赞
 */
export const deleteArticleLikings = id => {
    return request({
        method: 'DELETE',
        url: `/v1_0/article/likings/${id}`
    })
}

/**
 * 收藏文章
 */
export const postCollectionsArticle = data => {
    return request({
        method: 'POST',
        url: '/v1_0/article/collections',
        data
    })
}

/**
 * 取消对文章点赞
 */
export const deleteCollectionsArticle = id => {
    return request({
        method: 'DELETE',
        url: `/v1_0/article/collections/${id}`
    })
}
